package com.atguigu.ssyx.common.auth;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * ClassName: LoginMvcConfigurerAdapter
 * Package: com.atguigu.ssyx.common.auth
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-10-02
 * Time: 19:20
 */

//拦截器的配置类

@Configuration
public class LoginMvcConfigurerAdapter extends WebMvcConfigurationSupport {

    @Resource
    private RedisTemplate redisTemplate;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加自定义拦截器，设置路径
        registry.addInterceptor(
                new UserLoginInterceptor(redisTemplate))
                .addPathPatterns("/api/**")
                //排除的 不拦截的路径
                .excludePathPatterns("/api/user/weixin/wxLogin/*");
        super.addInterceptors(registry);
    }
}